package edu.cdnu.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import edu.cdnu.common.result.ResultEntity;
import edu.cdnu.pojo.TeacherPojo;
import edu.cdnu.service.TeacherService;

/**
 * 关于教师操作的Controller层
 * @author ASUS AsingZ
 */
@RestController
@RequestMapping("/teacher")
public class TeacherController {
	
	@Autowired
	private TeacherService teacherService;
	
	@PostMapping("/addOrUpdateTeacher")
	public ResultEntity<?> addOrUpdateTeacher(@RequestBody TeacherPojo teacherPojo){
		if(teacherPojo.getId()==null) {
			// 新增
			teacherService.addTeacher(teacherPojo);
		}else {
			// 修改
			teacherService.updateTeacher(teacherPojo);
		}
		
		return ResultEntity.createSuccessResult(null);
	}
}
